home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr27 / gs26.zip / BENCH.PS < prev    next >
Text File  |  1993-05-03  |  3KB  |  79 lines

  1. %    Copyright (C) 1993 Aladdin Enterprises.  All rights reserved.
  2. %    Distributed by Free Software Foundation, Inc.
  3. %
  4. % This file is part of Ghostscript.
  5. %
  6. % Ghostscript is distributed in the hope that it will be useful, but
  7. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. % to anyone for the consequences of using it or for whether it serves any
  9. % particular purpose or works at all, unless he says so in writing.  Refer
  10. % to the Ghostscript General Public License for full details.
  11. %
  12. % Everyone is granted permission to copy, modify and redistribute
  13. % Ghostscript, but only under the conditions described in the Ghostscript
  14. % General Public License.  A copy of this license is supposed to have been
  15. % given to you along with Ghostscript so you can know your rights and
  16. % responsibilities.  It should be in a file named COPYING.  Among other
  17. % things, the copyright notice and this notice must be preserved on all
  18. % copies.
  19.  
  20. % bench.ps
  21. % This file is a "wrapper" for benchmarking.
  22. % It writes timing results on a file called:
  23.  
  24. /BOF where { pop } {
  25.   /BOF (bench.out) def
  26. } ifelse
  27.  
  28.         % Make sure all execution occurs under a `save'.
  29.  
  30. save pop
  31.  
  32.         % Set the output device to an image device.
  33.  
  34. /Resolution where { pop } { /Resolution 100 def } ifelse
  35. [ Resolution 72.0 div 0 0 Resolution -72.0 div 0 792 ]
  36.   Resolution 8.5 mul cvi
  37.   Resolution 11.0 mul cvi
  38.   <00 ff>
  39. makeimagedevice
  40. setdevice
  41.  
  42.         % Redefine 'run' so that it collects timing information.
  43.  
  44. /.orig.run /run load def
  45. /.run.finish    % <file> <time> .run.finish <file>
  46.  { usertime exch sub
  47.    1 index =string cvs .bench.file exch writestring
  48.    .bench.file (: run time = ) writestring
  49.    =string cvs .bench.file exch writestring
  50.    .bench.file ( ms\n) writestring
  51.    .bench.file flushfile
  52.  } bind def
  53. /run        % <string> run -
  54.  {        % We construct a bound procedure here so that
  55.         % we can invoke run recursively.
  56.    cvlit
  57.    2
  58.     { /.orig.run load
  59.       save countdictstack 3 index usertime /.run.finish cvx
  60.       7 array astore cvx exec
  61.       exch countdictstack exch sub { end } repeat
  62.       exch restore
  63.     }
  64.    repeat
  65.         % Don't do the save & restore the last time.
  66.    /.orig.run load
  67.    1 index usertime /.run.finish cvx
  68.    5 array astore cvx exec pop
  69.  } bind odef
  70.  
  71.         % Force a quit after processing files.
  72.  
  73. /.bench.file BOF (w) file def
  74. /executive { .bench.file closefile quit } def
  75.  
  76.         % Make sure we don't incur any pauses.
  77.  
  78. /NOPAUSE true def
  79.